
module BdHelper  
  require 'libxml'
  def retrieveFile
      require 'MarcTools'          
          result=Rismid.find(:all, :conditions => ["h0001 not LIKE ?", "#{4}%"])           
            
          xml=LibXML::XML::Document.new()
        xml.root = LibXML::XML::Node.new("collection")                  
            
          result.each {|x| 
            x=x.xml
            old_xml=LibXML::XML::Document.string(x).root
          converter=MarcTools::MarcConverter.new
            marc_hash=converter.marc_to_hash(old_xml)            
                    marc_hash=converter.changeSubfieldCode(marc_hash,'650$3', '650$a')
                    marc_hash=converter.moveTag(marc_hash,'240$n', '240$a')
                    marc_hash=converter.moveTag(marc_hash,'300$c', '300$a')
                    marc_hash=converter.removeTagbyValue(marc_hash,'700$a', 'unbekannt')
                    marc_hash=converter.removeTagbyValue(marc_hash,'657$y', 'unbekannt')
                     new_xml=converter.hash_to_marc(marc_hash)
          a=xml.import(new_xml.root.child)
            xml.root << a
          #xml.root << new_xml.root.child
          }
    xml.save('myout.xml', :indent => true, :encoding => LibXML::XML::Encoding::UTF_8)      
        end
end
